This invention relates to loading of pages from object-oriented databases. More particularly, this invention relates to providing access frontier page(s) around all accessible memory pages loaded from an object-oriented database.
Some computer programs typically create, delete, modify and access a large number of data objects (xe2x80x9cobjectsxe2x80x9d) using one or more computer systems, which systems may be stand-alone or connected into a network. Such programs often use persistent object systems to maintain these objects and make them available for creation, deletion, modification and access on all or any of the computer systems. Persistent object systems, such as object-oriented databases, ensure the continuing availability of persistent objects by storing them in a non-volatile manner in an object server, such as a database or a file system, while allowing persistent objects to be moved into a computer system""s main memory to be accessed and manipulated by programs executing on the computer system.
When a program uses the persistent object system to access or modify an object stored on an object server, the persistent object system transfers the object from the object server to the main memory of the computer system (xe2x80x9cthe loaded objectxe2x80x9d) on which the program is executing. A conventional technique for loading such an object is to use the page protection systems of an existing virtual memory management system found in most operating systems to bring in the page containing the object into main memory.
Moreover, it is common for an object to contain references to other objects which references are typically represented in persistent object systems by persistent pointers in the object. The conventional persistent object system usually facilitates management of these pointers and referred objects. To this end, the page containing the loaded object is initialized typically by bringing that page into memory and replacing the persistent pointers in the page, which pointers cannot generally be used by the program to access and modify the referenced objects referred to by the persistent pointers, with main memory pointers that the program can use to access and modify the referenced objects in the virtual address space of the program""s process. Replacing a persistent pointer with a main memory pointer in this manner is called xe2x80x9cswizzlingxe2x80x9d the persistent pointer.
Thus, each persistent pointer in the page containing the loaded object is replaced with a main memory pointer and a page, marked as inaccessible (paged out), corresponding to each swizzled pointer is allocated by the page protection system. Virtual memory managers divide a main memory address space that is larger than actual main memory into pages of a fixed length. Thus, some of the pages in the main memory space are actually represented in the main memory, while others usually are xe2x80x9cpaged out.xe2x80x9d When a program attempts to dereference a main memory pointer to such an inaccessible page (or in other words attempt to access a referenced object on an inaccessible page), a page fault is generated and caught by a page fault interrupt handling routine of the persistent object system (e.g. a object-oriented database runtime). The page fault interrupt handling routine marks the faulted page as accessible (read/write) and loads (pages in) the faulted (inaccessible) page containing the referenced object from the object server into main memory using its persistent pointer. After loading, the page is further initialized as described earlier by swizzling of all pointers contained in the page and allocating any new pages, marked as inaccessible, corresponding to the swizzled pointers. After initialization is complete, the dereferencing operation is allowed to proceed. Subsequent attempts to dereference that main memory pointer proceed without further delay. Accordingly, persistent objects are advantageously loaded (instantiated in memory) as they are accessed by the program (i.e. on demand), rather than all at once at start-up time (i.e. eager swizzling).
A disadvantage and problem with this scheme results from the page fault interrupt handling routine running in the same process as the program. Once the routine has set a page to be accessible so that it can initialise the page (including swizzling pointers and allocating inaccessible pages), any other thread in that process can also access that page without causing a fault to be generated. If a thread does so before initialization is complete, the thread may get data in an incorrect state from that page because another thread has made changes to the data on the page. Similarly, any changes (writes) the thread makes may be overwritten by the page fault interrupt handling routine""s initialisation activities resulting in an incorrect state for later accessing threads.
A possible solution to this problem on some systems is to stop all threads while a fault is handled. Obviously, such a solution could severely degrade performance of a program as it waits for the fault to be handled. On multiprocessor systems, significant system resources might be left idle while a fault is being handled according to this solution.
Another possible solution to this problem on some systems is to provide multi-process capabilities to the program and other applications, transferring the pages from the database into shared memory and having the page fault interrupt handling routine communicate through some interprocess communication (IPC) mechanism with a second process (with its own set of page access rights) that does all the swizzling and initializing before making the pages accessible in the program""s address space. This solution however suffers from IPC xe2x80x9coverheadxe2x80x9d as well some systems limit the amount of shared address space that can be allocated thus possibly limiting the maximum size of program supported.
Another possible solution to this problem on some systems is to lessen the window of erroneous accessibility by raising the priority of the page fault interrupt handling routine as high as possible so that other threads have little chance of doing any work while the page fault interrupt handling routine is active. Clearly, this does not completely solve the problem; there is still a possibility of an incorrect state. Also, since the page fault interrupt handling routine will likely perform disk input/output (I/O) operations, it is inevitable that the routine will lose control of the central processing unit (CPU) regardless of its priority. Indeed, on multiprocessor systems, this solution would likely provide no additional protection from an incorrect state.
Accordingly, new and improved systems, methods, articles of manufacture tangibly embodying a program of instructions for loading pages from object-oriented databases is needed to overcome these and other disadvantages.
This invention provides new and improved systems, methods and articles of manufacture tangibly embodying a program of instructions for loading of pages from object-oriented databases.
A method, system and article of manufacture for providing access frontier page(s) around all accessible memory pages loaded from an object-oriented database to prevent simultaneous access by multiple threads to an initializing page. On initializing the root pages from an object-oriented database including bringing them into memory and swizzling the pointers in those pages, access frontier pages corresponding to each swizzled pointer are initialized and marked as inaccessible. All pointers contained in these access frontier pages that do not point to either an initialized and accessible page such as a root page or another access frontier page have page table entries created for them and are marked inaccessible. Any dereference of a pointer that causes a fault must be an access to an object on an access frontier page. A page fault interrupt handling routine proceeds, for each of the uninitialized pages pointed to by pointers on the faulted access frontier page, to convert it into an access frontier page by initializing a corresponding page from the object-oriented database, including bringing in the page and swizzling pointers in the page, setting up inaccessible page table entries for pointers that do not point to other frontier pages or accessible and initialized pages, and marking the page inaccessible. The faulted page is marked accessible thereafter and surrounded by access frontier pages.
In accordance with the invention, there is provided a method for loading pages from a persistent object system comprising the steps of, for each pointer in a page; initializing a corresponding page; for each corresponding page pointer not pointing to an initialized page, creating a page table entry for the corresponding page pointer and marking the page pointed to by the corresponding page pointer as inaccessible; and marking the corresponding page as inaccessible. The above method may also be provided wherein the step of initializing comprises bringing in the corresponding page from the persistent object system and if the corresponding page contains one or more pointers, swizzling one or more pointers in the corresponding page. Also, the page may be a root page of a program brought in from the persistent object system before execution of the program. And, the step of creating a page table entry may further comprise initializing the page pointed to by the corresponding page pointer. Also, the above method may further comprise the steps of, on dereferencing a pointer in the page that causes a fault; for each pointer not pointing to an initialized page in the page pointed to by the dereferencing pointer; initializing a corresponding page; for each corresponding page pointer not pointing to an initialized page; creating a page table entry for the corresponding page pointer and marking the page pointed by the corresponding page pointer as inaccessible; and marking the page pointed to by the dereferencing pointer as accessible. And it may further comprise the step of managing two or more dereferencing operations arising concurrently on two or more threads through a lock and synchronization mechanism.
There is also provided a method for protecting an accessible and initialized page having one or more pointers comprising the step of providing an access frontier page corresponding to each pointer in the initialized and accessible page. This method may further comprise the steps of, on dereferencing a pointer in the accessible and initialized page, providing an access frontier page corresponding to each pointer in a page corresponding to the dereferenced pointer; and marking the page corresponding to the dereferenced pointer as accessible. Additionally there may be provided the step of, if an access frontier page has one or more pointers not pointing to an access frontier page or an initialized and accessible page, creating a page table entry for each such access frontier page pointer and marking the page pointed by each such access frontier page as inaccessible.
Additionally, there is provided a method for dereferencing a pointer to an initialized and inaccessible page having one or more pointers, comprising the steps of, on dereferencing a pointer in the initialized and inaccessible page that causes a fault; for each pointer pointing to an uninitialized page in the page pointed to by the dereferenced pointer; initializing a corresponding page; for each corresponding page pointer not pointing to an initialized page; creating an uninitialized page and marking the uninitialized page inaccessible; and marking the page pointed to by the dereferencing pointer accessible.
There is also provided an article of manufacture comprising a computer usable medium having computer readable program code means therein for loading pages from a persistent object system, the computer readable program code means in said computer program product comprising computer readable code means for causing a computer to perform the above methods.
And, there is provided a computer system for loading pages from a persistent object system comprising means for initializing a corresponding page for each pointer in a page; means for creating a page table entry for the corresponding page pointer and marking the page pointed to by the corresponding page pointer as inaccessible for each corresponding page pointer not pointing to an initialized page; and means for marking the corresponding page as inaccessible.